package com.easthome.controller;

import com.easthome.common.RespResult;
import com.easthome.entity.UserInfo;
import com.easthome.pojo.form.OrdersAddForm;
import com.easthome.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

@RestController
@RequestMapping("/orders")
public class OrdersController {
@Autowired
private OrdersService ordersService;

@RequestMapping("/addOrder")
    public RespResult addOrder(@RequestBody OrdersAddForm form, @SessionAttribute UserInfo user){
   String  orderId =  ordersService.addOrder(form,user.getUserId());
    System.out.println("获取订单"+orderId+"以及id"+user.getUserId());
    return RespResult.success(orderId);
}
}
